package controller

import (
	"github.com/gofiber/fiber"
	"gowork/preferentialActivities/model"
)

type PreferentialActivitiesController struct {
	PreferentialActivities *model.PreferentialActivities
}

func (pac *PreferentialActivitiesController)InsertPreferentialActivities(c *fiber.Ctx){

	pac.PreferentialActivities = new(model.PreferentialActivities)

	var preferentialActivities model.PreferentialActivities
	c.BodyParser(&preferentialActivities)

	res , err := pac.PreferentialActivities.InsertPreferentialActivities(&preferentialActivities)
	if err != nil{
		c.JSON(fiber.Map{
			"code": 500,
			"data": nil,
			"message": err.Error(),
		})
		return
	}

	c.JSON(fiber.Map{
		"code": res["code"],
		"data": nil,
		"message": res["message"],
	})
	return
}

func (pac *PreferentialActivitiesController)InsertOrder(c *fiber.Ctx){

	pac.PreferentialActivities = new(model.PreferentialActivities)

	var putOrder model.PutOrder
	c.BodyParser(&putOrder)

	res , err := pac.PreferentialActivities.InsertOrder(&putOrder)
	if err != nil{
		c.JSON(fiber.Map{
			"code": 500,
			"data": nil,
			"message": err.Error(),
		})
		return
	}

	c.JSON(fiber.Map{
		"code": res["code"],
		"data": res["data"],
		"message": res["message"],
	})
	return
}